﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
    <link href="../Frozenui1.3/css/frozen.css" rel="stylesheet" />
    <script src="../JS/zepto.min.js"></script>
    <script src="../Frozenui1.3/js/frozen.js"></script>
    <script src="../JS/MobileCom.js?v=1.1"></script>
    <script src="../JS/avalon.mobile.min.js"></script>
    <style type="text/css">
        .ui-tab-content {
            margin-top: 0px;
        }

        .ui-border {
            padding: 10px;
        }

        .ui-list > li {
            margin: 3px;
        }

        .ui-border {
            background-color: #fff;
        }

            .ui-border .v {
                border-top: solid 1px #ede8e8;
                padding: 5px;
                margin-top: 10px;
                font-size: 12px;
            }

                .ui-border .v span {
                    font-size: 10px;
                    float: right;
                }

        .ui-label-s {
            margin-right: 5px;
        }

        .ms-controller, [ms-controller] {
            display: none;
        }

        .pullDown, .pullUp {
            background: #fff;
            height: 40px;
            line-height: 40px;
            padding: 5px 10px;
            border-bottom: 1px solid #ccc;
            font-weight: bold;
            font-size: 14px;
            color: #888;
        }

        .pullDownIcon, #pullUp .pullUpIcon {
            display: block;
            float: left;
            width: 40px;
            height: 40px;
            background: url(../Images/pull-icon@2x.png) 0 0 no-repeat;
            -webkit-background-size: 40px 80px;
            background-size: 40px 80px;
            -webkit-transition-property: -webkit-transform;
            -webkit-transition-duration: 250ms;
        }

        .pullDownIcon {
            -webkit-transform: rotate(0deg) translateZ(0);
        }

        .pullUpIcon {
            -webkit-transform: rotate(-180deg) translateZ(0);
        }

        .flip .pullDownIcon {
            -webkit-transform: rotate(-180deg) translateZ(0);
        }

        .flip .pullUpIcon {
            -webkit-transform: rotate(0deg) translateZ(0);
        }

        .loading .pullDownIcon {
            background-position: 0 100%;
            -webkit-transform: rotate(0deg) translateZ(0);
            -webkit-transition-duration: 0ms;
            -webkit-animation-name: loading;
            -webkit-animation-duration: 2s;
            -webkit-animation-iteration-count: infinite;
            -webkit-animation-timing-function: linear;
        }

        @-webkit-keyframes loading {
            from {
                -webkit-transform: rotate(0deg) translateZ(0);
            }

            to {
                -webkit-transform: rotate(360deg) translateZ(0);
            }
        }

        .ms-controller, [ms-controller] {
            display: none;
        }
    </style>
    <title>报销记录</title>
</head>
<body>
    <div class="ui-footer ui-footer-stable ui-btn-group ui-border-t">
        <button class="ui-btn-lg" onclick="back()">
            返回
        </button>
        <button class="ui-btn-lg ui-btn-primary" onclick="adddata()">
            新增报销
        </button>
    </div>

 <div class="ui-tab">
    <ul class="ui-tab-nav ui-border-b">
        <li class="current">我的报销</li>
        <li>我的审批</li>
        <li>部门报销</li>
    </ul>
    <ul class="ui-tab-content" style="width:300%">
        <li style="height:auto">
            <div class="ui-form ui-border-t">

                <ul class="ui-list ui-list-pure" style="background-color:#f6f0f0;" ms-controller="bxlist">
                    <li class="ui-border ui-label-list" ms-repeat-el="ctData">
                        <a class="ui-list-info" href="#" ms-click="vieww(el)">
                            <p>
                                <span class="ui-txt-info">
                                    <label class="ui-label-s">
                                        {{el.BXDate|date("yyyy-MM-dd")}}
                                    </label> {{el.ShenQingRen}}  {{el.BXZJE}}元
                                </span>
                                <span >{{spzt(el.StateName)|html}}</span>
                            </p>
                            <p class="ui-txt-justify" style="overflow: hidden; word-wrap: break-word;">描述：{{MobileCom.convstr (el.BXContent,40)}}</p>
                        </a>
                    </li>
                </ul>
            </div>

            <div id="bxpullDown" class="pullDown loading">
                <span class="pullDownIcon"></span><span class="pullDownLabel">数据加载中...</span>
            </div>
        </li>
        <li style="height:0">
            <div class="ui-form ui-border-t">

                <ul class="ui-list ui-list-pure" style="background-color:#f6f0f0;" ms-controller="shlist">
                    <li class="ui-border ui-label-list" ms-repeat-el="ctData">
                        <a class="ui-list-info" href="#" ms-click="vieww(el)">
                            <p>
                                <span class="ui-txt-info">
                                    <label class="ui-label-s">
                                        {{el.BXDate|date("yyyy-MM-dd")}}
                                    </label> {{el.ShenQingRen}}  {{el.BXZJE}}元
                                </span>
                                <span>{{spzt("正在审批")|html}}</span>
                            </p>
                            <p class="ui-txt-justify" style="overflow: hidden; word-wrap: break-word;">描述：{{MobileCom.convstr (el.BXContent,40)}}</p>
                        </a>
                    </li>
                </ul>
            </div>

            <div id="shpullDown" class="pullDown loading">
                <span class="pullDownIcon"></span><span class="pullDownLabel">数据加载中...</span>
            </div>
        </li>
        <li style="height:0">
            <div class="ui-form ui-border-t">

                <ul class="ui-list ui-list-pure" style="background-color:#f6f0f0;" ms-controller="cslist">
                    <li class="ui-border ui-label-list" ms-repeat-el="ctData">
                        <a class="ui-list-info" href="#" ms-click="vieww(el)">
                            <p>
                                <span class="ui-txt-info">
                                    <label class="ui-label-s">
                                        {{el.BXDate|date("yyyy-MM-dd")}}
                                    </label> {{el.ShenQingRen}}  {{el.BXZJE}}元
                                </span>
                                <span>{{spzt(el.StateName)|html}}</span>
                            </p>
                            <p class="ui-txt-justify" style="overflow: hidden; word-wrap: break-word;">描述：{{MobileCom.convstr (el.BXContent,40)}}</p>
                        </a>
                    </li>
                </ul>
            </div>

            <div id="cspullDown" class="pullDown loading">
                <span class="pullDownIcon"></span><span class="pullDownLabel">数据加载中...</span>
            </div>
        </li>
    </ul>
</div>

        <script>

            document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
                //隐藏右上角按钮
                WeixinJSBridge.call('hideOptionMenu');
            });

            window.addEventListener('load', function () {

                var tab = new fz.Scroll('.ui-tab', {
                    role: 'tab'
                });

                /* 滑动开始前 */
                tab.on('beforeScrollStart', function (from, to) {
                    // from 为当前页，to 为下一页
                })

                /* 滑动结束 */
                tab.on('scrollEnd', function (curPage) {
                    // curPage 当前页
                });

            })

            window.localStorage.removeItem("page1");
            window.localStorage.setItem("page1", 1);
            window.localStorage.removeItem("page2");
            window.localStorage.setItem("page2", 1);
            window.localStorage.removeItem("page3");
            window.localStorage.setItem("page3", 1);

            window.localStorage.removeItem("isjz1");
            window.localStorage.setItem("isjz1", 0);
            window.localStorage.removeItem("isjz2");
            window.localStorage.setItem("isjz2", 0);
            window.localStorage.removeItem("isjz3");
            window.localStorage.setItem("isjz3", 0);

            //if (MobileCom.getCookie("szhlcode") == null) {
            //    //MobileCom.setCookie("szhlcode", "80814792-f1d7-437d-988d-e43ea373b9b8", 7);
            //    //MobileCom.setCookie("szhlusername", "86258010@qq.com", 7);
            //    MobileCom.setCookie("szhlcode", "2b30c572-a7b1-4b08-bfb1-ff19f5fc9679", 7);
            //    MobileCom.setCookie("szhlusername", "1522516861@qq.com", 7);
            //}

            var bxmodel = avalon.define({
                $id: "bxlist",
                ctData: [],
                isforbid: "",
                vieww: function (el) {
                    window.location = "UI_JFBX_INFO.html?id=" + el.ID + "&t=0&r=" + Math.random();
                }

            });

            var shmodel = avalon.define({
                $id: "shlist",
                ctData: [],
                isforbid: "",
                vieww: function (el) {
                    window.location = "UI_JFBX_INFO.html?id=" + el.ID + "&t=1&r=" + Math.random();
                }

            });

            var csmodel = avalon.define({
                $id: "cslist",
                ctData: [],
                isforbid: "",
                queryusers: "",
                vieww: function (el) {
                    window.location = "UI_JFBX_INFO.html?id=" + el.ID + "&t=2&r=" + Math.random();
                }

            });

            $(window).scroll(function () {

                if ($(document).height() - $(this).scrollTop() - $(this).height() < 40) {
                    loadMore();
                }

            })

            function bx() {
                var isjz1 = window.localStorage.getItem("isjz1");
                if (isjz1 == 0) {
                    window.localStorage.setItem("isjz1", 1);
                    var page = window.localStorage.getItem("page1");
                    $.getJSON("/API/WXAPI.ashx?Action=GETUSERJFBXLIST_PAGE&r=" + Math.random(), { P2: page }, function (r) {
                        if (r.ErrorMsg == "") {
                            if (r.Result.length > 0) {
                                bxmodel.ctData.pushArray(r.Result);
                                bxmodel.isforbid = r.Result1;
                                if (r.Result.length < 8) {
                                    window.localStorage.setItem("page1", 0);
                                    $("#bxpullDown").find(".pullDownLabel").text("已加载所有数据");
                                    $("#bxpullDown").removeClass("loading");
                                    $("#bxpullDown span").eq(0).hide();

                                }
                                else {
                                    var page = window.localStorage.getItem("page1");
                                    window.localStorage.setItem("page1", parseInt(page) + 1);
                                }
                            } else {
                                var page = window.localStorage.getItem("page1");
                                if (page == "1") {
                                    $("#bxpullDown").find(".pullDownLabel").text("没有数据");
                                    $("#bxpullDown").removeClass("loading");
                                    $("#bxpullDown span").eq(0).hide();
                                }
                                else {
                                    window.localStorage.setItem("page1", 0);
                                    $("#bxpullDown").find(".pullDownLabel").text("已加载所有数据");
                                    $("#bxpullDown").removeClass("loading");
                                    $("#bxpullDown span").eq(0).hide();
                                }
                            }

                        } else {

                        }
                        window.localStorage.setItem("isjz1", 0);
                    })
                }
            }

            function sh() {
                var isjz2 = window.localStorage.getItem("isjz2");
                if (isjz2 == 0) {
                    window.localStorage.setItem("isjz2", 1);
                    var page = window.localStorage.getItem("page2");
                    $.getJSON("/API/WXAPI.ashx?Action=GETDSHDATA_PAGE&r=" + Math.random(), { P1: "JFBX", P2: page }, function (r) {
                        if (r.ErrorMsg == "") {
                            if (r.Result.length > 0) {
                                shmodel.ctData.pushArray(r.Result);
                                shmodel.isforbid = r.Result1;
                                if (r.Result.length < 8) {
                                    window.localStorage.setItem("page2", 0);
                                    $("#shpullDown").find(".pullDownLabel").text("已加载所有数据");
                                    $("#shpullDown").removeClass("loading");
                                    $("#shpullDown span").eq(0).hide();

                                }
                                else {
                                    var page = window.localStorage.getItem("page2");
                                    window.localStorage.setItem("page2", parseInt(page) + 1);
                                }
                            } else {
                                var page = window.localStorage.getItem("page2");
                                if (page == "1") {
                                    $("#shpullDown").find(".pullDownLabel").text("没有数据");
                                    $("#shpullDown").removeClass("loading");
                                    $("#shpullDown span").eq(0).hide();
                                }
                                else {
                                    window.localStorage.setItem("page2", 0);
                                    $("#shpullDown").find(".pullDownLabel").text("已加载所有数据");
                                    $("#shpullDown").removeClass("loading");
                                    $("#shpullDown span").eq(0).hide();
                                }
                            }

                        } else {

                        }
                        window.localStorage.setItem("isjz2", 0);
                    })
                }
            }

            function cs() {
                var isjz3 = window.localStorage.getItem("isjz3");
                if (isjz3 == 0) {
                    window.localStorage.setItem("isjz3", 1);
                    var page = window.localStorage.getItem("page3");
                    $.getJSON("/API/WXAPI.ashx?Action=GETUSERJFBXLIST_PAGE&r=" + Math.random(), { P2: page, "b": "-1", "QUSER": csmodel.queryusers }, function (r) {
                        if (r.ErrorMsg == "") {
                            if (r.Result.length > 0) {
                                csmodel.ctData.pushArray(r.Result);
                                csmodel.isforbid = r.Result1;
                                if (r.Result.length < 8) {
                                    window.localStorage.setItem("page3", 0);
                                    $("#cspullDown").find(".pullDownLabel").text("已加载所有数据");
                                    $("#cspullDown").removeClass("loading");
                                    $("#cspullDown span").eq(0).hide();

                                }
                                else {
                                    var page = window.localStorage.getItem("page3");
                                    window.localStorage.setItem("page3", parseInt(page) + 1);
                                }
                            } else {
                                var page = window.localStorage.getItem("page3");
                                if (page == "1") {
                                    $("#cspullDown").find(".pullDownLabel").text("没有数据");
                                    $("#cspullDown").removeClass("loading");
                                    $("#cspullDown span").eq(0).hide();
                                }
                                else {
                                    window.localStorage.setItem("page3", 0);
                                    $("#cspullDown").find(".pullDownLabel").text("已加载所有数据");
                                    $("#cspullDown").removeClass("loading");
                                    $("#cspullDown span").eq(0).hide();
                                }
                            }

                        } else {

                        }
                        window.localStorage.setItem("isjz3", 0);
                    })
                }
            }


            function loadMore() {

                if ($(".ui-tab-nav li").eq(0).hasClass("current")) {
                    var page = window.localStorage.getItem("page1");
                    if (page != "0") {
                        bx();
                    }
                }
                else if ($(".ui-tab-nav li").eq(1).hasClass("current")) {
                    var page = window.localStorage.getItem("page2");
                    if (page != "0") {
                        sh();
                    }
                }
                else {
                    var page = window.localStorage.getItem("page3");
                    if (page != "0") {
                        cs();
                    }
                }
            }

            avalon.ready(function () {
                bx();
                sh();
                $.getJSON('/API/SZHLAPI.ashx?Action=GETQUERYUSER', { P1: "1" }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        csmodel.queryusers = resultData.Result ? resultData.Result : "-1";
                        cs();
                    }
                })
            })

            function spzt(strsp) {
                if (strsp == "正在审批") {
                    return '<div class="ui-badge-muted" style="float:right">正在审批</div>';
                }
                else if (strsp == "已审批") {
                    return '<div class="ui-badge-muted" style="background-color:green;float:right">已审批</div>';
                }
                else if (strsp == "已退回") {
                    return '<div class="ui-badge" style="float:right">已退回</div>';
                }
            }
            function back() {
                window.location.replace("UI_BASE_PAGE.html?r=" + Math.random());
            }
            function adddata() {
                window.location = "UI_JFBX_BXMX.html?r=" + Math.random();
            }
    </script>

</body>
</html>
